// -----------------------------------------------------------------------
// <copyright file="ProgressEN.cs" company="VDC-IT" author="LTDUC">
//      Copyright (c) VDC-IT. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace VDC.VONE.ENTITIES
{
    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using Microsoft.ApplicationBlocks.Data;
    using VDC.COMMON;
    
    /// <summary>
    /// Class Progress
    /// </summary>
    public class ProgressEN : EntityEN
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgressEN" /> class
        /// </summary>
        public ProgressEN()
        {
            this.ProgressId = 0;
            this.Name = string.Empty;
        }
        
        /// <summary>
        /// Gets or sets ProgressId
        /// </summary>
        public int ProgressId { get; set; }
        
        /// <summary>
        /// Gets or sets Name
        /// </summary>
        public string Name { get; set; }
        
        /// <summary>
        /// Gets ProfileTypeProgresses
        /// </summary>
        public IList<ProfileTypeProgressEN> ProfileTypeProgresses
        {
            get
            {
                try
                {
                    IList<ProfileTypeProgressEN> lstProfileTypeProgress = new List<ProfileTypeProgressEN>();
                    var reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, Constants.StorepProcedure.VOneProfileTypeProgressGetByProgressId, this.ProgressId);
                    while (reader.Read())
                    {
                        ProfileTypeProgressEN profileTypeProgress = new ProfileTypeProgressEN();
                        if (!reader.IsDBNull(0))
                        {
                            profileTypeProgress.ProfileTypeProgressId = reader.GetInt32(0);
                        }

                        if (reader.IsDBNull(1))
                        {
                            profileTypeProgress.ProgressId = reader.GetInt32(1);
                        }

                        if (reader.IsDBNull(2))
                        {
                            profileTypeProgress.ProfileTypeId = reader.GetInt32(2);
                        }

                        if (reader.IsDBNull(3))
                        {
                            profileTypeProgress.DecideDays = reader.GetInt32(3);
                        }

                        lstProfileTypeProgress.Add(profileTypeProgress);
                    }

                    reader.Close();
                    reader.Dispose();
                    return lstProfileTypeProgress;
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }
    }
}
